﻿@using PinLayoutMVC.Models
@model PinLayoutMVC.Models.QuestionModel
@{
    ViewBag.Title = "Take Survey";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>
    Take Survey</h2>
@using (Html.BeginForm("TakeSurvey", "Survey", new { surveyId = ViewData["surveyId"], questionId = ViewData["questionId"] }, FormMethod.Post, new { @id = "takesurveyform" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Question: #@Html.Encode(Model.Number)</legend>
        <div class="question">@Html.Encode(Model.Question)</div>
        @if (Model.Description != "" && Model.Description != null)
        {
            <div class="questionDescription">
                (@Html.Encode(Model.Description))</div>
        }
        <br />
        <div class="answer">
            @Html.Hidden("id", Model.ID)
            @switch (Model.Type)
            {
                case QuestionModel.EQuestionType.radiobutton:
                    foreach (var Answer in Model.Answers)
                    {   
                @Html.RadioButton("answerId", Answer.ID);
                @Html.Encode(Answer.Text);
                <br />
                    }
                    break;
            }
        </div>
        <br />
        <div class="customanswer">
            @Model.FeedbackText<br />
            @if (Model.AllowFeedback || Model.Type.Equals(QuestionModel.EQuestionType.open))
            {
                @Html.TextArea("customAnswer");
            }
        </div>
        <br />
        <input type="submit" value="Next" />
    </fieldset>
}